package com.llh.demo4tree.controller

import com.llh.demo4tree.entity.ResponseVO
import com.llh.demo4tree.entity.TreeNodeMoveVO
import com.llh.demo4tree.entity.TreeVO
import com.llh.demo4tree.service.TreeNodeService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

/**
 *
 * Created At 2021/8/5 16:29
 * @author llh
 */
@RestController
@RequestMapping("tree")
class TreeController {
    @Autowired
    private lateinit var treeNodeService: TreeNodeService

    @GetMapping
    fun tree(nodeId: Int?): TreeVO? {
        return treeNodeService.findSubTree(nodeId)
    }

    @PostMapping("move")
    fun move(
        @RequestBody moveVO: TreeNodeMoveVO
    ): ResponseVO {
        return treeNodeService.moveNode(moveVO)
    }
}